package com.reggie.lotterysystem.dao.mapper;


import com.reggie.lotterysystem.controller.param.UserPasswordLoginParam;
import com.reggie.lotterysystem.dao.dataobject.Encrypt;
import com.reggie.lotterysystem.dao.dataobject.UserDO;
import jakarta.validation.constraints.NotBlank;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select count(*) from user where email = #{mail}")
    int conutByMail(String mail);

    @Select("select count(*) from user where phone_number = #{phoneNumber}")
    int conutByPhone( Encrypt phoneNumber);

    @Insert("insert into user(email,identity,password,phone_number,user_name)"
              + " values (#{email},#{identity},#{password},#{phoneNumber},#{userName})")
    @Options(useGeneratedKeys = true ,keyProperty = "id" , keyColumn = "id")
    void insert(UserDO userDO);

    @Select("select * from user where phone_number = #{phoneNumber}")
    UserDO selectByPhoneNumber(Encrypt phoneNumber);

    @Select("select * from user where email = #{email}")
    UserDO selectByMail(String email);

//    @Select("<script> " +
//    " select * from user" +
//    " <if test = \"identity != null\">" +
//    " where identity = #{identity}" +
//    " </if>" +
//    " order by id desc" +
//    " /<script>")
    List<UserDO> selectUserListByIdentity(String identity);

    List<Long> selectExistByIds(List<Long> userIds);

    List<UserDO> batchSelectByIds( List<Long> userIds);
}
